package com.wn.controller;

import com.alibaba.druid.filter.AutoLoad;
import com.wn.bean.Owner;
import com.wn.service.OwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author yellow Docter
 * @date 2024-06-27
 * @desc 蜗牛创想：www.woniuxy.com
 */
@RestController
@RequestMapping("owner")
public class OwnerController {

    @Autowired
    private OwnerService ownerService;

    @GetMapping("/list")
    public Owner OwnerController(int id) {
        Owner owner = ownerService.getOwnerById(id);
        return owner;
    }

    @GetMapping("/list/all")
    public List<Owner> listAll() {
        List<Owner> list = ownerService.listOwner();
        return list;
    }

    @PostMapping("/save")
    public String saveOwner(Owner owner) {
        boolean flag = ownerService.saveOwner(owner);
        return flag ? "success":"error";
    }

    @PostMapping("/update")
    public String updateOwner(Owner owner) {
        boolean flag = ownerService.updateOwnerById(owner);
        return flag ? "success":"error";
    }

}
